export function wxpayOrder(data) {
	if (typeof WeixinJSBridge === 'undefined') {
		if (document.addEventListener) {
			document.addEventListener('WeixinJSBridgeReady', onBridgeReady(data), false)
		} else if (document.attachEvent) {
			document.attachEvent('WeixinJSBridgeReady', onBridgeReady(data))
			document.attachEvent('onWeixinJSBridgeReady', onBridgeReady(data))
		}
	} else {
		onBridgeReady(data)
	}
}

function onBridgeReady(etr) {
	let that = this
	WeixinJSBridge.invoke( //这个对象只有微信浏览器支持
		'getBrandWCPayRequest', etr,
		function(res) {
			if (res.err_msg == 'get_brand_wcpay_request:ok') {
				uni.$u.toast('支付成功')
				setTimeout(() => { //支付成功后的展示页面
					uni.navigateBack()
				}, 1500)
			} else {
				uni.$u.toast('支付失败')
			}
		})

}